import React,{PropTypes} from 'react';
import '../styles/main.scss';
import {modifyItem,deleteItem} from '../redux/actions/todoMVC.js'

class ToolManager extends React.Component {
  constructor(props) {
	  
    super(props);
	console.log("这额最后个一"+JSON.stringify(this.props));
  };
  modify(index){
    this.props.dispatch(modifyItem(index));
  }
  delete(index){
    this.props.dispatch(deleteItem(index));
  }
  renderAction(value,index) {
    return (
      <div style={{height:"20px",width:"100%"}} onClick={this.delete.bind(this,index)}>
      </div>
    )
  }
  
  render() {
    return (
	  <ul>
        {this.props.dataSource.map(function(item,index) {
           return <li key={index} data={item} onClick={() => {this.props.dispatch(deleteItem(index))}}>{item.preview}</li>;
        })}
      </ul>
    );
  };
}

ToolManager.propTypes = {
	name:React.PropTypes.string
};
ToolManager.defaultProps = {
  dataSource:[],
  dispatch:{}
};

export default ToolManager;